

import { defineStore } from 'pinia'

export const useTokenStore = defineStore('token', {
    state() {
        return {
            token: '',
            userInfo: null,   // 普通用户信息
            adminInfo: null   // 管理员信息
        }
    },
    actions: {
        setToken(newToken) {
            this.token = newToken
        },
        removeToken() {
            this.token = ''
            this.userInfo = null
            this.adminInfo = null
        },
        setUserInfo(info) {
            this.userInfo = info
        },
        setAdminInfo(info) {
            this.adminInfo = info
        }
    },
    persist: {
        enabled: true,
    }
})

